home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 109
/
Vol 109.iso
/
games
/
basket_a.swf
/
scripts
/
frame_194
/
DoAction.as
Wrap
Text File
|
2008-11-12
|
4KB
|
146 lines
function goNico()
{
if(_root.balle.launch)
{
updateNico();
_root.balle.oldY = _root.balle._y;
_root.balle._x += _root.balle.myVitesseX;
_root.balle._y -= _root.balle.myVitesseY;
_root.balle._rotation += 1;
if(_root.balle._y > _root.balle.oldY)
{
_root.balle.direction = "bas";
}
else
{
_root.balle.direction = "haut";
}
_root.balle.myVitesseY *= _root.balle.friction;
_root.balle.myVitesseX *= _root.balle.friction;
_root.balle.myVitesseY -= _root.balle.gravite;
if(_root.balle._y >= 320)
{
_root.balle._y = 319;
if(Math.abs(_root.balle.myVitesseY) < 10)
{
_root.balle.launch = false;
if(_root.scoreloose == 0)
{
_root.gotoAndStop("ending");
clearInterval(intervalID);
}
else
{
_root.play();
}
}
else
{
playSound(_root.balle._x,_root.balle.myVitesseY);
}
_root.balle.myVitesseY *= -1 * _root.balle.restitution;
_root.balle.restitution -= 0.1;
_root.balle.etat = "out";
}
if(_root.balle.hitTest(_root.paniertop) && _root.balle._x > 375)
{
if(_root.balle.etat != "out")
{
_root.balle.myVitesseY *= -1 * _root.balle.restitution;
_root.balle.resitution -= 0.1;
_root.balle.myVitesseX += 1;
_root.filet.play();
}
}
if(_root.balle.hitTest(_root.panier))
{
_root.balle.myVitesseX *= -1;
_root.balle.myVitesseX *= _root.balle.friction;
if(_root.balle.etat != "out")
{
_root.filet.play();
}
}
if(_root.balle.hitTest(_root.panier2))
{
_root.balle.myVitesseX *= -1;
_root.balle.myVitesseX *= _root.balle.friction;
}
if(_root.balle._x >= 485 && _root.balle._x < 515 && _root.balle._y >= 180)
{
_root.balle._x = 484;
_root.balle.myVitesseX *= -1;
_root.balle.myVitesseX *= _root.balle.friction;
playSound(_root.balle._x,_root.balle.myVitesseX);
}
if(_root.balle._x >= 422 && _root.balle._x < 465 && _root.balle._y >= 35 && _root.balle._y <= 100)
{
_root.balle._x = 421;
playSound(_root.balle._x,_root.balle.myVitesseX);
_root.balle.myVitesseX *= -1;
_root.balle.myVitesseX *= 0.5 * _root.balle.friction;
}
if(_root.balle.hitTest(_root.score) && _root.balle.direction == "bas" && _root.balle.etat != "out" && _root.score.scoreOn == true)
{
_root.scoreaff = _root.scoreaff + 1;
_root.score.scoreOn = false;
_root.filet.filet2.filet3.play();
}
}
updateAfterEvent();
}
function updateNico()
{
anglenico = Math.atan2(_root.balle._y - 200,_root.balle._x - _root.nico._x);
anglenico2 = anglenico / 0.017453292519943295 + 20;
if(anglenico2 > 80)
{
anglenico2 = 80;
}
else if(anglenico2 < -60)
{
anglenico2 = -60;
}
_root.nico.tete._rotation = anglenico2 * 0.2;
}
function playSound(x, speed)
{
var ballX = x * 100 / 560;
var pan = -50 + ballX * 2;
if(x < 0)
{
var pan = -100;
}
else if(x > 560)
{
var pan = 100;
}
var maxSpeed = 15;
var minSpeed = 1;
var speed = Math.abs(speed);
var factor = speed / (maxSpeed - minSpeed);
if(speed < minSpeed)
{
var factor = 0;
}
var volume = factor * 100;
if(volume > 0)
{
bounce = new Sound(son);
bounce.attachSound("bounce");
bounce.setPan(pan);
bounce.setVolume(volume);
bounce.start();
}
}
force = 5;
myAngle = 80;
_root.nico.tete._rotation = 0;
balle._x = random(200) + 100;
nico._x = balle._x;
pointer._x = _root.nico._x + 5;
origAngle = 0.017453292519943295 * myAngle;
var intervalID;
intervalID = setInterval(goNico,20);
stop();